package com.requiem.hist_group_manage_springboot.controller;

import com.requiem.hist_group_manage_springboot.exception.R;
import com.requiem.hist_group_manage_springboot.model.EvaluationModel;
import com.requiem.hist_group_manage_springboot.model.StudentModel;
import com.requiem.hist_group_manage_springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    StudentService studentService;

    @GetMapping("/getList")
    R getList() {
        return studentService.getList();
    }

    @GetMapping("/get")
    R getByID() {
        return studentService.getByID();
    }

    @GetMapping("/getLog")
    R getLog() {
        return studentService.getLog();
    }

    @PostMapping("/add")
    R add(@RequestBody StudentModel studentModel) {
        return studentService.add(studentModel);
    }

    @DeleteMapping("/delete")
    R delete() {
        return studentService.delete();
    }

    @PostMapping("/edit")
    R edit(@RequestBody StudentModel studentModel) {
        return studentService.edit(studentModel);
    }

    //加入或退出小组
    @PostMapping("/join")
    R joinGroup(@RequestParam int studentId, int groupId) {
        return studentService.joinGroup(studentId, groupId);
    }

    @PostMapping("/exit")
    R exitGroup(@RequestParam int studentId, int groupId) {
        return studentService.exitGroup(studentId, groupId);
    }

    //搜索
    @PostMapping("/Search")
    R getSearch(@RequestBody StudentModel studentModel) {
        return studentService.SearchList(studentModel);
    }

    // 评论功能
    @GetMapping("/getTeacher")
    R getTeacher(@RequestParam int groupId) {
        return studentService.getTeacher(groupId);
    }

    @GetMapping("/getEvaluation")
    R getEvaluation(@RequestParam int studentId) {
        return studentService.getEvaluation(studentId);
    }

    @PostMapping("/addEvaluation")
    R addEvaluation(@RequestBody EvaluationModel evaluationModel) {
        return studentService.addEvaluation(evaluationModel);
    }

    //重置密码
    @PostMapping("/resetPassword")
    R resetPassword(@RequestParam int id, @RequestParam String password) {
        return studentService.resetPassword(id, password);
    }
}
